package ch15;

import org.junit.Test;

import static org.junit.Assert.*;

/**
 * Created by 春旺 on 2017/10/16.
 */
public class LinkedQueueTest {
    LinkedQueue queue = new LinkedQueue();
    @Test
    public void dequeue() throws Exception {
        queue.enqueue("2");
        assertEquals(1,queue.size());
        queue.dequeue();
        assertEquals(0,queue.size());
    }

    @Test
    public void first() throws Exception {
       queue.enqueue(2);
       queue.enqueue("春旺");
       assertEquals(2,queue.first());
       queue.dequeue();
       assertEquals("春旺",queue.first());
       queue.dequeue();

    }

    @Test
    public void isEmpty() throws Exception {
        LinkedQueue queue2 = new LinkedQueue();
        assertEquals(true,queue2.isEmpty());
        queue2.enqueue(2);
        assertEquals(false,queue2.isEmpty());
    }

    @Test
    public void size() throws Exception {
        LinkedQueue queue2 = new LinkedQueue();
        assertEquals(0,queue2.size());
        for (int i = 0;i< 10;i++){
            queue2.enqueue(i);
        }
        assertEquals(10,queue2.size());
    }
    @Test
    public void testToString() throws Exception{

        queue.enqueue(2016);
        queue.enqueue(2324);

        assertEquals("20162324",queue.toString());
        queue.dequeue();
        assertEquals("2324",queue.toString());
    }

}